{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "030082e9-edee-40b6-9f17-b6a683f2e334",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import requests\n",
    "from dotenv import load_dotenv\n",
    "import bs4\n",
    "from bs4 import BeautifulSoup\n",
    "import lxml\n",
    "from IPython.display import Markdown, display\n",
    "from openai import OpenAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "c87e997d-e1d6-4b6f-9c76-3fb1d607f7cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "e450cb33-1ae4-435e-b155-35f2bd7ab78e",
   "metadata": {},
   "outputs": [],
   "source": [
    "headers={\n",
    " \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\"\n",
    "} \n",
    "#a dictionary named header so that we can grab same html code as the user ,and also to avoid blocks,captcha and error403"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "63a57fb7-79db-444b-968b-c9314b1f3d3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Website:\n",
    "    def __init__(self,url):\n",
    "        self.url=url\n",
    "        response= requests.get(url,headers=headers,timeout=30)\n",
    "        soup=BeautifulSoup(response.content,'lxml')\n",
    "        self.title=soup.title.string if soup.title else \"No title found\"#scraping the content\n",
    "        for irrelevant in soup.body([\"script\", \"style\", \"img\", \"input\"]):#cleaning the content\n",
    "            irrelevant.decompose()\n",
    "            #using .get_text() method of Beautiful soup\n",
    "        self.text = soup.body.get_text(separator=\"\\n\", strip=True)#creating space between different lines and removing leading whitespaces by strip=true"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "7369159d-1f36-43c9-b7e7-a0b65b56426b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Latest and Trending Entertainment News, Celebrity News, Movie News, Breaking News | Entertainment - Times of India\n",
      "Sign In\n",
      "TOI\n",
      "Go to\n",
      "TOI\n",
      "Etimes\n",
      "home\n",
      "cinema\n",
      "news\n",
      "movie reviews\n",
      "movie listings\n",
      "box office\n",
      "anime\n",
      "previews\n",
      "did you know\n",
      "videos\n",
      "showtimes\n",
      "blogs\n",
      "awards\n",
      "News\n",
      "entertainment\n",
      "Trending\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Sudhanshu: At 52, John, Dino all of them look like rockstars - EXCLUSIVE\n",
      "Sudhanshu Pandey, recognized from 'Band Of Boys' and 'Anupama', defies his 50 years with his fitness. He credits his peers like Dino Moria, Arjun Rampal, and John Abraham for inspiring him to maintain a fit and youthful appearance. Pandey also admires Anil Kapoor's energy and dedication, motivating him to continue prioritizing fitness and inspiring others.\n",
      "Previous\n",
      "Sonakshi breaks silence on her rift with Luv and Kussh\n",
      "Madhuri once chased Aamir with hockey stick for THIS reason\n",
      "Ranbir-Raj Kapoor, Diljit-Hania, Samay-IGL: Top 5 news\n",
      "Big B's savage reply to troll over cybercrime callertune\n",
      "Anushka on keeping kids Vamika, Akaay away from public eye\n",
      "Apoorva Mukhija recalls witnessing gender bias at home\n",
      "Danish influencer seeks help to find papads from Big B\n",
      "Sunjay Kapur's reception pics with Priya Sachdev goes viral\n",
      "Big B schools trolls commenting 'buddha sathiya gaya hai'\n",
      "Anushka on how she and Virat divide parenting duties\n",
      "Brahmaji reacts to Vishnu's 7,000-acre land in New Zealand\n",
      "Diljit says THIS amidst trolling for working with Hania\n",
      "Riddhi found it ridiculous to like SRK's mother in Jawan\n",
      "Priya Sachdev once called husband Sunjay Kapur ‘misunderstood’\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "Hindi\n",
      "See All\n",
      "Sudhanshu: At 52, John, Dino all of them look like rockstars - EXCLUSIVE\n",
      "Sudhanshu Pandey, recognized from 'Band Of Boys' and 'Anupama', defies his 50 years with his fitness. He credits his peers like Dino Moria, Arjun Rampal, and John Abraham for inspiring him to maintain a fit and youthful appearance. Pandey also admires Anil Kapoor's energy and dedication, motivating him to continue prioritizing fitness and inspiring others.\n",
      "Sonakshi breaks silence on her rift with Luv and Kussh\n",
      "Madhuri once chased Aamir with hockey stick for THIS reason\n",
      "Ranbir-Raj Kapoor, Diljit-Hania, Samay-IGL: Top 5 news\n",
      "Anushka on keeping kids Vamika, Akaay away from public eye\n",
      "Anushka Sharma and Virat Kohli are committed to shielding their children, Vamika and Akaay, from the constant glare of public attention. In a recent interview, Anushka emphasized the couple's focus on instilling strong values and ensuring a normal upbringing for their kids.\n",
      "Apoorva Mukhija recalls witnessing gender bias at home\n",
      "Regional\n",
      "When Samantha’s class 10 mark sheet got leaked\n",
      "Throwback to when a nostalgic memory made its way across the internet — Samantha Ruth Prabhu’s Class 10 mark sheet! The actress’s charming on-screen presence and grounded personality were once again in the spotlight as her old school report card began doing the rounds on social media.\n",
      "Actor Tushar Ghadigaonkar passes away at 34\n",
      "‘Kuberaa’ Twitter review: Netizens calls it a ‘Blockbuster’\n",
      "Mammootty’s health- Brittas says actor doing well\n",
      "Kavya Madhavan’s father P. Madhavan passes away\n",
      "‘The Raja Saab’ teaser: Prabhas shines in this horror comedy\n",
      "Mammootty’s father-in-law P S Abu passes away\n",
      "Videos\n",
      "See All\n",
      "Previous\n",
      "03:07\n",
      "Ananya Panday’s Garden Bond With Parrots Wins Hearts\n",
      "88 views | 2 hours ago\n",
      "03:14\n",
      "Sameera Reddy’s Healing Journey Through Yoga\n",
      "31 views | 2 hours ago\n",
      "03:13\n",
      "Kriti Kharbanda’s Modern Maharani Look Stuns Instagram\n",
      "26 views | 2 hours ago\n",
      "03:12\n",
      "Bobby Deol Meets Diljit Dosanjh: Punjabi Power Goes Viral\n",
      "81 views | 2 hours ago\n",
      "03:19\n",
      "‘Sitaare Zameen Par’: Riteish Deshmukh’s Emotional Shoutout For Genelia’s Big Win\n",
      "162 views | 2 hours ago\n",
      "03:26\n",
      "Varun Dhawan Stuns With 50 Push-Ups Alongside Army Cadets on Border 2 Set\n",
      "21 views | 2 hours ago\n",
      "03:00\n",
      "VIDYA BALAN TURNS HEADS WITH CASUAL AIRPORT LOOK\n",
      "16 views | 2 hours ago\n",
      "03:05\n",
      "MANDHIRA KAPUR BREAKS DOWN IN EMOTIONAL POST FOR LATE BROTHER SUNJAY KAPUR\n",
      "1.2K views | 2 hours ago\n",
      "03:28\n",
      "SALMAN KHAN TAKES A BRUTAL DIG AT SOHAIL’S DIVORCE ON NATIONAL TV\n",
      "185 views | 2 hours ago\n",
      "03:15\n",
      "RAJINIKANTH CAUSES FAN RIOT DURING ‘JAILER 2’ SHOOT IN MYSORE\n",
      "26 views | 2 hours ago\n",
      "03:10\n",
      "IBRAHIM ALI KHAN KISSES HIS DOG AT AIRPORT IN HEARTWARMING FAREWELL\n",
      "20 views | 3 hours ago\n",
      "03:09\n",
      "ANUPAMAA SET GUTTED IN MASSIVE FIRE | CREW ESCAPES, CINE BODY DEMANDS ACTION\n",
      "1.2K views | 3 hours ago\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "11\n",
      "World\n",
      "See All\n",
      "Aamir to Tom: Celebs on a mission to 'Save Cinema'\n",
      "'How to Train Your Dragon' beats '28 Years Later' and 'Elio' to top the US box office on second weekend\n",
      "Blake Lively is heartbroken after friendship ends with Taylor Swift; accepts the music mogul won't be returning - Deets inside\n",
      "Selena-Hailey UNFOLLOW each other amid Bieber drama\n",
      "Judge gives Baldoni access to Blake-Taylor messages\n",
      "Trending Now\n",
      "# Sidharth Malhotra-Kiara Advani\n",
      "# AbRam Khan-Taimur Ali Khan\n",
      "# Janhvi Kapoor\n",
      "# Salman Khan\n",
      "# Hema Malini\n",
      "# Salman Khan\n",
      "# Gauri Khan\n",
      "# Shah Rukh Khan\n",
      "# Chahatt Khanna\n",
      "Visual Stories\n",
      "See All\n",
      "Previous\n",
      "Kuberaa’s Sameera to Pushpa’s Srivalli: Rashmika Mandanna’s most iconic on-screen avatars\n",
      "Ahaana Krishna’s ethereal photo series is straight out of a dream\n",
      "Rashmika Mandanna to Rakul Preet Singh: Best pictures of the week featuring south actresses\n",
      "Gauri Khan's most loved saree looks - An ode to modern day elegance\n",
      "​South Indian beauties whose smiles will light up your Monday\n",
      "Karishma Tanna Slays Every Frame\n",
      "Tamannaah Bhatia’s traditional looks\n",
      "Malavika Mohanan's radiant pics\n",
      "​Neha Shetty stuns in every shade of blue\n",
      "Thalapathy Vijay’s top 10 blockbuster movies worth re-watching!\n",
      "​In pic: Mesmerizing looks of Shruti Haasan​\n",
      "Dushara Vijayan’s Most Elegant Fashion Moments\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "More Stories\n",
      "Sonakshi Sinha breaks silence on her rumoured rift with brothers Luv and Kussh Sinha: 'My effort is always to support them...'\n",
      "Madhuri Dixit once chased Aamir Khan with a hockey stick for THIS reason on sets of Dil: 'People fool you and you believe them'\n",
      "Mohanlal declines to continue as president at AMMA’s general body meeting- Deets Inside\n",
      "Blockbusters Ranbir Kapoor turned down: Films that became hits without him\n",
      "Anushka Sharma reveals why she and Virat Kohli are keeping their children Vamika and Akaay away from the public eye: 'We don't want to raise brats'\n",
      "Apoorva Mukhija recalls witnessing gender bias at home: 'My mother did it all, but father got credit for showing up at PTMs'\n",
      "Amitabh Bachchan gives a savage reply to a troll over his viral cybercrime caller tune: 'Sarkar ko bolo bhai..'\n",
      "Danish influencer asks fans to help her find papads from Amitabh Bachchan; netizens say 'he also used to grow basmati rice'\n",
      "Days after his untimely demise, Sunjay Kapur's reception photos with Priya Sachdev goes viral; Looked dashing in hand embroidered shoes, written 'I do'\n",
      "Priyanka Chopra Jonas recollects walking into a trap set by John Cena, Idris Elba on sets of 'Heads of State'\n",
      "Bobby Deol's London vacation sparks fan frenzy: viral video shows actor posing for selfies outside restaurant\n",
      "Amitabh Bachchah gives befitting replies to 'buddha sathiya gaya hai', ‘ganja’ comments by trolls: 'Ek din, Bhagwan naa kare voh din jaldi aaye...'\n",
      "Sai Pallavi’s best performances\n",
      "Brahmaji clears the air about Vishnu Manchu purchasing 7,000-acre land in New Zealand: 'I was pulling their leg as usual...'\n",
      "Anushka Sharma reveals how she and Virat Kohli divide the parenting duties: 'I will be the primary caregiver, he plays round the year'\n",
      "Ranbir Kapoor's 'Awara' look sparks rumours of Raj Kapoor tribute, Diljit Dosanjh slammed for working with Hania Aamir in Sardaar Ji 3: Top 5 news\n",
      "Has Kiara Advani been approached to play Meena Kumari in her biopic? Here's what we know\n",
      "Top 5  psychological Anime every thriller fan must watch\n",
      "Load More Stories\n",
      "# Latest Movies 2025\n",
      "# Best Bollywood Movies 2025\n",
      "# Hollywood Movie 2025\n",
      "# Tamil Movies 2025\n",
      "# Telugu Movies 2025\n",
      "# Malayalam Movies 2025\n",
      "# Kannada Movies 2025\n",
      "# Marathi Movies 2025\n",
      "# Bengali Movies 2025\n",
      "# Top Rated Movies 2025\n",
      "# Best Hindi Movies\n",
      "# Best English Movies\n",
      "Hot on the Web\n",
      "Salman Khan\n",
      "Karisma Kapoor\n",
      "Jaideep Ahlawat\n",
      "Blood Pressure\n",
      "Big Cat Species\n",
      "Trisha\n",
      "Sitaare Zameen Par Review\n",
      "Ancient Indigenous Tribes\n",
      "Hair Growth Tips\n",
      "Kidney Health\n",
      "Kuberaa Review\n",
      "Blake Lively\n",
      "Reverse Fatty Liver\n",
      "Skincare Hacks\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Baby Girl Names\n",
      "Diljit Dosanjh\n",
      "Kidney Disease Symptoms\n",
      "Javed Akhtar\n",
      "Heart Attack\n",
      "Ram Kapoor Diet\n",
      "Liver Damage\n",
      "Kuberaa Movie Review\n",
      "Gauri Khan\n",
      "Baba Vanga Prediction\n",
      "Baby Boy Names\n",
      "Navjot Singh Sidhu\n",
      "Housefull 5 Box Office Collection\n",
      "DNA Movie Review\n",
      "Kidney Damage Symptoms\n",
      "Popular Waterfalls In India\n",
      "Linkedin Ceo On AI Killing Jobs\n",
      "Tesla Robotaxi\n",
      "Early Cancer Detection\n",
      "Harvard Research Reveals\n",
      "American Destinations Explore Without Passport\n",
      "Amouranth\n",
      "Mouth Larvae\n",
      "Doomsday Fish\n",
      "Salman Khan AVM\n",
      "Ginger Health Tips\n",
      "Trending Topics\n",
      "Latest Movies\n",
      "Bollywood Movies\n",
      "Hollywood Movies\n",
      "Tamil Movies 2025\n",
      "Telugu Movies 2025\n",
      "Malayalam Movies 2025\n",
      "Kannada Movies 2025\n",
      "Marathi Movies 2025\n",
      "Bengali Movies 2025\n",
      "Top Rated Movies 2025\n",
      "Best Hindi Movies\n",
      "Best English Movies\n",
      "Best Telugu Movies\n",
      "Best Tamil Movies\n",
      "Best Malayalam Movies\n",
      "Best Kannada Movies\n",
      "Best Bengali Movies\n",
      "Upcoming Hindi Movies\n",
      "Best Movies Of All Time\n",
      "Best Hindi Movies of All Time\n",
      "Latest English Movies\n",
      "Latest Malayalam Movies\n",
      "English TV News\n",
      "Tamil TV News\n",
      "Telugu TV News\n",
      "Malayalam TV News\n",
      "Kannada TV News\n",
      "Movie Reviews\n",
      "Bhojpuri Cinema News\n",
      "Gujarati Cinema News\n",
      "Popular Categories\n",
      "Viral News\n",
      "K Pop News\n",
      "Web Series News\n",
      "Anime News\n",
      "Upcoming English Movies\n",
      "Upcoming Tamil Movies\n",
      "Upcoming Telugu Movies\n",
      "Upcoming Malayalam Movies\n",
      "Upcoming Kannada Movies\n",
      "Fashion Tips\n",
      "Travel News\n",
      "Entertainment News\n",
      "Bollywood News\n",
      "Tollywood News\n",
      "Kollywood News\n",
      "Mollywood News\n",
      "Food News\n",
      "Latest Hindi Movies\n",
      "Latest Tamil Movies\n",
      "Parenting Tips\n",
      "Home Remedies\n",
      "Weight Loss\n",
      "Beauty Tips\n",
      "Parenting Tips\n",
      "Hindi Videos\n",
      "Hindi Video Songs\n",
      "Bhojpuri Music Videos\n",
      "Latest Telugu Movies\n",
      "Bhojpuri Music Video\n",
      "Hindi TV News\n",
      "Latest News\n",
      "NHL free agency turns spicy as Mitch Marner and Connor McDavid eye shorter deals to cash in later\n",
      "Olive Ridley turtle washed ashore at Polem\n",
      "Who is Thomas Fugate? Meet the 22-year-old leading Trump's terrorism unit amid Iran fiasco\n",
      "'And that's why Putin's the boss': Trump rebukes former Russian President Medvedev; warns against treating 'N word casually'\n",
      "Govt plans ₹10cr road on Bicholim-Dodamarg route\n",
      "Former WWE star Batista eyed for Road House 2 sequel\n",
      "Sonakshi Sinha breaks silence on her rumoured rift with brothers Luv and Kussh Sinha: 'My effort is always to support them...'\n",
      "Andre Agassi and Steffi Graf’s son Jaden Agassi shows love for girlfriend Catherine Holt’s bold new photo from bedroom series\n",
      "Is WWE planning to change Cody Rhodes’ iconic entrance theme song ‘Kingdom’?\n",
      "Velumani says he didn’t attend RSS event in Coimbatore\n",
      "Strait of Hormuz: Oil supply not an issue for India; 'pricing is a bigger concern,' what experts say\n",
      "Madhuri Dixit once chased Aamir Khan with a hockey stick for THIS reason on sets of Dil: 'People fool you and you believe them'\n",
      "As commissions fall, India’s ride-hailing firms test viability of flat-fee economics\n",
      "Analysing what Trump’s strikes mean for Iran\n",
      "Trump's clarification on 'Iran regime change' divides MAGA further: JD Vance, Hegseth, Marco Rubio 'humiliated'\n",
      "Laughter Chefs 2: Krushna Abhishek roasts Rahul Vaidya for his in-famous feud with cricketer Virat Kohli\n",
      "“I could have passed Dan Ticktum”: Edoardo Mortara regrets Attack Mode strategy at Jakarta E-Prix\n",
      "India vs England Test: Sunil Gavaskar calls for Rishabh Pant's signature somersault celebration, wicketkeeper politely declines - WATCH\n",
      "Copyright © 2025 Bennett, Coleman & Co. Ltd. All rights reserved. For reprint rights: Times Syndication Service\n",
      "Follow us on\n"
     ]
    }
   ],
   "source": [
    "gossip= Website(\"https://timesofindia.indiatimes.com/entertainment\")\n",
    "print(gossip.title)\n",
    "print(gossip.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "a6f30380-1b91-48e4-9c86-df0369e2e675",
   "metadata": {},
   "outputs": [],
   "source": [
    "system_prompt = \"\"\"\n",
    "You are a stylish and culturally aware assistant who specializes in summarizing and discussing fashion trends, celebrity style, entertainment news, and television gossip.\n",
    "\n",
    "You stay updated on Hollywood, Bollywood, and the television world—including celebrity rumors, drama, reality TV updates, show recaps, and behind-the-scenes stories.\n",
    "\n",
    "When summarizing content, be engaging, concise, and insightful. Focus on what's trending, who's wearing what, and what everyone is talking about in fashion and entertainment. Maintain a fun yet informative tone, like a pop culture expert writing for a lifestyle magazine.\n",
    "\n",
    "If content includes TV gossip, highlight key rumors, casting updates, fan reactions, and noteworthy moments from popular shows.\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "30822d5c-d518-451c-b31f-44afa2a3b37a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def user_prompt_for(website):\n",
    "    user_prompt = f\"\"\"The following text is extracted from a website titled: \"{website.title}\".\n",
    "\n",
    "Please analyze this content and provide a short and engaging summary in **Markdown format**.\n",
    "\n",
    "If the page contains:\n",
    "- 🧵 Fashion trends: mention standout styles, designers, or events.\n",
    "- 🗣️ TV gossip: highlight any drama, casting news, or fan reactions.\n",
    "- 🎬 Celebrity updates (Hollywood/Bollywood): include relevant quotes, fashion moments, or event mentions.\n",
    "- 📺 Show recaps: summarize what happened and any major twists.\n",
    "\n",
    "Keep the summary clear, fun, and informative. Use bullet points if multiple themes appear. If there is no meaningful content, say: *“No relevant summary could be generated.”*\n",
    "\n",
    "Website Content:\n",
    "{website.text}\n",
    "\"\"\"\n",
    "    return user_prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "5a25e90f-20a0-44ac-a96c-575ae974a45f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The following text is extracted from a website titled: \"Latest and Trending Entertainment News, Celebrity News, Movie News, Breaking News | Entertainment - Times of India\".\n",
      "\n",
      "Please analyze this content and provide a short and engaging summary in **Markdown format**.\n",
      "\n",
      "If the page contains:\n",
      "- 🧵 Fashion trends: mention standout styles, designers, or events.\n",
      "- 🗣️ TV gossip: highlight any drama, casting news, or fan reactions.\n",
      "- 🎬 Celebrity updates (Hollywood/Bollywood): include relevant quotes, fashion moments, or event mentions.\n",
      "- 📺 Show recaps: summarize what happened and any major twists.\n",
      "\n",
      "Keep the summary clear, fun, and informative. Use bullet points if multiple themes appear. If there is no meaningful content, say: *“No relevant summary could be generated.”*\n",
      "\n",
      "Website Content:\n",
      "Sign In\n",
      "TOI\n",
      "Go to\n",
      "TOI\n",
      "Etimes\n",
      "home\n",
      "cinema\n",
      "news\n",
      "movie reviews\n",
      "movie listings\n",
      "box office\n",
      "anime\n",
      "previews\n",
      "did you know\n",
      "videos\n",
      "showtimes\n",
      "blogs\n",
      "awards\n",
      "News\n",
      "entertainment\n",
      "Trending\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Javed Akhtar\n",
      "Diljit Dosanjh\n",
      "Jaideep Ahlawat\n",
      "Karisma Kapoor\n",
      "Gauri Khan\n",
      "Blake Lively\n",
      "Trisha Krishnan\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Housefull 5\n",
      "Kuberaa Movie Review\n",
      "Sitaare Zameen Par Movie Review\n",
      "Sudhanshu: At 52, John, Dino all of them look like rockstars - EXCLUSIVE\n",
      "Sudhanshu Pandey, recognized from 'Band Of Boys' and 'Anupama', defies his 50 years with his fitness. He credits his peers like Dino Moria, Arjun Rampal, and John Abraham for inspiring him to maintain a fit and youthful appearance. Pandey also admires Anil Kapoor's energy and dedication, motivating him to continue prioritizing fitness and inspiring others.\n",
      "Previous\n",
      "Sonakshi breaks silence on her rift with Luv and Kussh\n",
      "Madhuri once chased Aamir with hockey stick for THIS reason\n",
      "Ranbir-Raj Kapoor, Diljit-Hania, Samay-IGL: Top 5 news\n",
      "Big B's savage reply to troll over cybercrime callertune\n",
      "Anushka on keeping kids Vamika, Akaay away from public eye\n",
      "Apoorva Mukhija recalls witnessing gender bias at home\n",
      "Danish influencer seeks help to find papads from Big B\n",
      "Sunjay Kapur's reception pics with Priya Sachdev goes viral\n",
      "Big B schools trolls commenting 'buddha sathiya gaya hai'\n",
      "Anushka on how she and Virat divide parenting duties\n",
      "Brahmaji reacts to Vishnu's 7,000-acre land in New Zealand\n",
      "Diljit says THIS amidst trolling for working with Hania\n",
      "Riddhi found it ridiculous to like SRK's mother in Jawan\n",
      "Priya Sachdev once called husband Sunjay Kapur ‘misunderstood’\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "Hindi\n",
      "See All\n",
      "Sudhanshu: At 52, John, Dino all of them look like rockstars - EXCLUSIVE\n",
      "Sudhanshu Pandey, recognized from 'Band Of Boys' and 'Anupama', defies his 50 years with his fitness. He credits his peers like Dino Moria, Arjun Rampal, and John Abraham for inspiring him to maintain a fit and youthful appearance. Pandey also admires Anil Kapoor's energy and dedication, motivating him to continue prioritizing fitness and inspiring others.\n",
      "Sonakshi breaks silence on her rift with Luv and Kussh\n",
      "Madhuri once chased Aamir with hockey stick for THIS reason\n",
      "Ranbir-Raj Kapoor, Diljit-Hania, Samay-IGL: Top 5 news\n",
      "Anushka on keeping kids Vamika, Akaay away from public eye\n",
      "Anushka Sharma and Virat Kohli are committed to shielding their children, Vamika and Akaay, from the constant glare of public attention. In a recent interview, Anushka emphasized the couple's focus on instilling strong values and ensuring a normal upbringing for their kids.\n",
      "Apoorva Mukhija recalls witnessing gender bias at home\n",
      "Regional\n",
      "When Samantha’s class 10 mark sheet got leaked\n",
      "Throwback to when a nostalgic memory made its way across the internet — Samantha Ruth Prabhu’s Class 10 mark sheet! The actress’s charming on-screen presence and grounded personality were once again in the spotlight as her old school report card began doing the rounds on social media.\n",
      "Actor Tushar Ghadigaonkar passes away at 34\n",
      "‘Kuberaa’ Twitter review: Netizens calls it a ‘Blockbuster’\n",
      "Mammootty’s health- Brittas says actor doing well\n",
      "Kavya Madhavan’s father P. Madhavan passes away\n",
      "‘The Raja Saab’ teaser: Prabhas shines in this horror comedy\n",
      "Mammootty’s father-in-law P S Abu passes away\n",
      "Videos\n",
      "See All\n",
      "Previous\n",
      "03:07\n",
      "Ananya Panday’s Garden Bond With Parrots Wins Hearts\n",
      "88 views | 2 hours ago\n",
      "03:14\n",
      "Sameera Reddy’s Healing Journey Through Yoga\n",
      "31 views | 2 hours ago\n",
      "03:13\n",
      "Kriti Kharbanda’s Modern Maharani Look Stuns Instagram\n",
      "26 views | 2 hours ago\n",
      "03:12\n",
      "Bobby Deol Meets Diljit Dosanjh: Punjabi Power Goes Viral\n",
      "81 views | 2 hours ago\n",
      "03:19\n",
      "‘Sitaare Zameen Par’: Riteish Deshmukh’s Emotional Shoutout For Genelia’s Big Win\n",
      "162 views | 2 hours ago\n",
      "03:26\n",
      "Varun Dhawan Stuns With 50 Push-Ups Alongside Army Cadets on Border 2 Set\n",
      "21 views | 2 hours ago\n",
      "03:00\n",
      "VIDYA BALAN TURNS HEADS WITH CASUAL AIRPORT LOOK\n",
      "16 views | 2 hours ago\n",
      "03:05\n",
      "MANDHIRA KAPUR BREAKS DOWN IN EMOTIONAL POST FOR LATE BROTHER SUNJAY KAPUR\n",
      "1.2K views | 2 hours ago\n",
      "03:28\n",
      "SALMAN KHAN TAKES A BRUTAL DIG AT SOHAIL’S DIVORCE ON NATIONAL TV\n",
      "185 views | 2 hours ago\n",
      "03:15\n",
      "RAJINIKANTH CAUSES FAN RIOT DURING ‘JAILER 2’ SHOOT IN MYSORE\n",
      "26 views | 2 hours ago\n",
      "03:10\n",
      "IBRAHIM ALI KHAN KISSES HIS DOG AT AIRPORT IN HEARTWARMING FAREWELL\n",
      "20 views | 3 hours ago\n",
      "03:09\n",
      "ANUPAMAA SET GUTTED IN MASSIVE FIRE | CREW ESCAPES, CINE BODY DEMANDS ACTION\n",
      "1.2K views | 3 hours ago\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "11\n",
      "World\n",
      "See All\n",
      "Aamir to Tom: Celebs on a mission to 'Save Cinema'\n",
      "'How to Train Your Dragon' beats '28 Years Later' and 'Elio' to top the US box office on second weekend\n",
      "Blake Lively is heartbroken after friendship ends with Taylor Swift; accepts the music mogul won't be returning - Deets inside\n",
      "Selena-Hailey UNFOLLOW each other amid Bieber drama\n",
      "Judge gives Baldoni access to Blake-Taylor messages\n",
      "Trending Now\n",
      "# Sidharth Malhotra-Kiara Advani\n",
      "# AbRam Khan-Taimur Ali Khan\n",
      "# Janhvi Kapoor\n",
      "# Salman Khan\n",
      "# Hema Malini\n",
      "# Salman Khan\n",
      "# Gauri Khan\n",
      "# Shah Rukh Khan\n",
      "# Chahatt Khanna\n",
      "Visual Stories\n",
      "See All\n",
      "Previous\n",
      "Kuberaa’s Sameera to Pushpa’s Srivalli: Rashmika Mandanna’s most iconic on-screen avatars\n",
      "Ahaana Krishna’s ethereal photo series is straight out of a dream\n",
      "Rashmika Mandanna to Rakul Preet Singh: Best pictures of the week featuring south actresses\n",
      "Gauri Khan's most loved saree looks - An ode to modern day elegance\n",
      "​South Indian beauties whose smiles will light up your Monday\n",
      "Karishma Tanna Slays Every Frame\n",
      "Tamannaah Bhatia’s traditional looks\n",
      "Malavika Mohanan's radiant pics\n",
      "​Neha Shetty stuns in every shade of blue\n",
      "Thalapathy Vijay’s top 10 blockbuster movies worth re-watching!\n",
      "​In pic: Mesmerizing looks of Shruti Haasan​\n",
      "Dushara Vijayan’s Most Elegant Fashion Moments\n",
      "Next\n",
      "1\n",
      "2\n",
      "3\n",
      "More Stories\n",
      "Sonakshi Sinha breaks silence on her rumoured rift with brothers Luv and Kussh Sinha: 'My effort is always to support them...'\n",
      "Madhuri Dixit once chased Aamir Khan with a hockey stick for THIS reason on sets of Dil: 'People fool you and you believe them'\n",
      "Mohanlal declines to continue as president at AMMA’s general body meeting- Deets Inside\n",
      "Blockbusters Ranbir Kapoor turned down: Films that became hits without him\n",
      "Anushka Sharma reveals why she and Virat Kohli are keeping their children Vamika and Akaay away from the public eye: 'We don't want to raise brats'\n",
      "Apoorva Mukhija recalls witnessing gender bias at home: 'My mother did it all, but father got credit for showing up at PTMs'\n",
      "Amitabh Bachchan gives a savage reply to a troll over his viral cybercrime caller tune: 'Sarkar ko bolo bhai..'\n",
      "Danish influencer asks fans to help her find papads from Amitabh Bachchan; netizens say 'he also used to grow basmati rice'\n",
      "Days after his untimely demise, Sunjay Kapur's reception photos with Priya Sachdev goes viral; Looked dashing in hand embroidered shoes, written 'I do'\n",
      "Priyanka Chopra Jonas recollects walking into a trap set by John Cena, Idris Elba on sets of 'Heads of State'\n",
      "Bobby Deol's London vacation sparks fan frenzy: viral video shows actor posing for selfies outside restaurant\n",
      "Amitabh Bachchah gives befitting replies to 'buddha sathiya gaya hai', ‘ganja’ comments by trolls: 'Ek din, Bhagwan naa kare voh din jaldi aaye...'\n",
      "Sai Pallavi’s best performances\n",
      "Brahmaji clears the air about Vishnu Manchu purchasing 7,000-acre land in New Zealand: 'I was pulling their leg as usual...'\n",
      "Anushka Sharma reveals how she and Virat Kohli divide the parenting duties: 'I will be the primary caregiver, he plays round the year'\n",
      "Ranbir Kapoor's 'Awara' look sparks rumours of Raj Kapoor tribute, Diljit Dosanjh slammed for working with Hania Aamir in Sardaar Ji 3: Top 5 news\n",
      "Has Kiara Advani been approached to play Meena Kumari in her biopic? Here's what we know\n",
      "Top 5  psychological Anime every thriller fan must watch\n",
      "Load More Stories\n",
      "# Latest Movies 2025\n",
      "# Best Bollywood Movies 2025\n",
      "# Hollywood Movie 2025\n",
      "# Tamil Movies 2025\n",
      "# Telugu Movies 2025\n",
      "# Malayalam Movies 2025\n",
      "# Kannada Movies 2025\n",
      "# Marathi Movies 2025\n",
      "# Bengali Movies 2025\n",
      "# Top Rated Movies 2025\n",
      "# Best Hindi Movies\n",
      "# Best English Movies\n",
      "Hot on the Web\n",
      "Salman Khan\n",
      "Karisma Kapoor\n",
      "Jaideep Ahlawat\n",
      "Blood Pressure\n",
      "Big Cat Species\n",
      "Trisha\n",
      "Sitaare Zameen Par Review\n",
      "Ancient Indigenous Tribes\n",
      "Hair Growth Tips\n",
      "Kidney Health\n",
      "Kuberaa Review\n",
      "Blake Lively\n",
      "Reverse Fatty Liver\n",
      "Skincare Hacks\n",
      "Kuberaa Box Office Collection\n",
      "Sitaare Zameen Par Box Office Collection\n",
      "Baby Girl Names\n",
      "Diljit Dosanjh\n",
      "Kidney Disease Symptoms\n",
      "Javed Akhtar\n",
      "Heart Attack\n",
      "Ram Kapoor Diet\n",
      "Liver Damage\n",
      "Kuberaa Movie Review\n",
      "Gauri Khan\n",
      "Baba Vanga Prediction\n",
      "Baby Boy Names\n",
      "Navjot Singh Sidhu\n",
      "Housefull 5 Box Office Collection\n",
      "DNA Movie Review\n",
      "Kidney Damage Symptoms\n",
      "Popular Waterfalls In India\n",
      "Linkedin Ceo On AI Killing Jobs\n",
      "Tesla Robotaxi\n",
      "Early Cancer Detection\n",
      "Harvard Research Reveals\n",
      "American Destinations Explore Without Passport\n",
      "Amouranth\n",
      "Mouth Larvae\n",
      "Doomsday Fish\n",
      "Salman Khan AVM\n",
      "Ginger Health Tips\n",
      "Trending Topics\n",
      "Latest Movies\n",
      "Bollywood Movies\n",
      "Hollywood Movies\n",
      "Tamil Movies 2025\n",
      "Telugu Movies 2025\n",
      "Malayalam Movies 2025\n",
      "Kannada Movies 2025\n",
      "Marathi Movies 2025\n",
      "Bengali Movies 2025\n",
      "Top Rated Movies 2025\n",
      "Best Hindi Movies\n",
      "Best English Movies\n",
      "Best Telugu Movies\n",
      "Best Tamil Movies\n",
      "Best Malayalam Movies\n",
      "Best Kannada Movies\n",
      "Best Bengali Movies\n",
      "Upcoming Hindi Movies\n",
      "Best Movies Of All Time\n",
      "Best Hindi Movies of All Time\n",
      "Latest English Movies\n",
      "Latest Malayalam Movies\n",
      "English TV News\n",
      "Tamil TV News\n",
      "Telugu TV News\n",
      "Malayalam TV News\n",
      "Kannada TV News\n",
      "Movie Reviews\n",
      "Bhojpuri Cinema News\n",
      "Gujarati Cinema News\n",
      "Popular Categories\n",
      "Viral News\n",
      "K Pop News\n",
      "Web Series News\n",
      "Anime News\n",
      "Upcoming English Movies\n",
      "Upcoming Tamil Movies\n",
      "Upcoming Telugu Movies\n",
      "Upcoming Malayalam Movies\n",
      "Upcoming Kannada Movies\n",
      "Fashion Tips\n",
      "Travel News\n",
      "Entertainment News\n",
      "Bollywood News\n",
      "Tollywood News\n",
      "Kollywood News\n",
      "Mollywood News\n",
      "Food News\n",
      "Latest Hindi Movies\n",
      "Latest Tamil Movies\n",
      "Parenting Tips\n",
      "Home Remedies\n",
      "Weight Loss\n",
      "Beauty Tips\n",
      "Parenting Tips\n",
      "Hindi Videos\n",
      "Hindi Video Songs\n",
      "Bhojpuri Music Videos\n",
      "Latest Telugu Movies\n",
      "Bhojpuri Music Video\n",
      "Hindi TV News\n",
      "Latest News\n",
      "NHL free agency turns spicy as Mitch Marner and Connor McDavid eye shorter deals to cash in later\n",
      "Olive Ridley turtle washed ashore at Polem\n",
      "Who is Thomas Fugate? Meet the 22-year-old leading Trump's terrorism unit amid Iran fiasco\n",
      "'And that's why Putin's the boss': Trump rebukes former Russian President Medvedev; warns against treating 'N word casually'\n",
      "Govt plans ₹10cr road on Bicholim-Dodamarg route\n",
      "Former WWE star Batista eyed for Road House 2 sequel\n",
      "Sonakshi Sinha breaks silence on her rumoured rift with brothers Luv and Kussh Sinha: 'My effort is always to support them...'\n",
      "Andre Agassi and Steffi Graf’s son Jaden Agassi shows love for girlfriend Catherine Holt’s bold new photo from bedroom series\n",
      "Is WWE planning to change Cody Rhodes’ iconic entrance theme song ‘Kingdom’?\n",
      "Velumani says he didn’t attend RSS event in Coimbatore\n",
      "Strait of Hormuz: Oil supply not an issue for India; 'pricing is a bigger concern,' what experts say\n",
      "Madhuri Dixit once chased Aamir Khan with a hockey stick for THIS reason on sets of Dil: 'People fool you and you believe them'\n",
      "As commissions fall, India’s ride-hailing firms test viability of flat-fee economics\n",
      "Analysing what Trump’s strikes mean for Iran\n",
      "Trump's clarification on 'Iran regime change' divides MAGA further: JD Vance, Hegseth, Marco Rubio 'humiliated'\n",
      "Laughter Chefs 2: Krushna Abhishek roasts Rahul Vaidya for his in-famous feud with cricketer Virat Kohli\n",
      "“I could have passed Dan Ticktum”: Edoardo Mortara regrets Attack Mode strategy at Jakarta E-Prix\n",
      "India vs England Test: Sunil Gavaskar calls for Rishabh Pant's signature somersault celebration, wicketkeeper politely declines - WATCH\n",
      "Copyright © 2025 Bennett, Coleman & Co. Ltd. All rights reserved. For reprint rights: Times Syndication Service\n",
      "Follow us on\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(user_prompt_for(gossip))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "c039ab7c-88ee-475d-a93e-b26711d3ed4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def messages_for(website):\n",
    "    return [\n",
    "        {\"role\": \"system\", \"content\": system_prompt},\n",
    "        {\"role\": \"user\", \"content\": user_prompt_for(website)}\n",
    "    ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "dd1fee35-6cc9-4995-8b5e-b93d80488364",
   "metadata": {},
   "outputs": [],
   "source": [
    "def summarize(url):\n",
    "    website = Website(url)\n",
    "    response = openai.chat.completions.create(\n",
    "        model = \"llama3.2\",\n",
    "        messages = messages_for(website)\n",
    "    )\n",
    "    return response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed09dad8-93bb-417e-b07b-183d2eba1ec5",
   "metadata": {},
   "outputs": [],
   "source": [
    "summarize(\"https://timesofindia.indiatimes.com/entertainment\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "16a57eed-eba5-4f75-84f2-d44a67b36047",
   "metadata": {},
   "outputs": [],
   "source": [
    "def display_summary(url):\n",
    "    summary = summarize(url)\n",
    "    display(Markdown(summary))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25af6217-6944-4c95-b156-0899dfcf0b83",
   "metadata": {},
   "outputs": [],
   "source": [
    "display_summary(\"https://timesofindia.indiatimes.com/entertainment\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "29daa2d4-9d92-40ae-a0c4-dd2fdacf3f80",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
